package com.goods.business.converter;

import com.goods.common.model.business.ProductCategory;
import com.goods.common.model.business.Supplier;
import com.goods.common.vo.business.ProductCategoryTreeNodeVO;
import com.goods.common.vo.business.SupplierVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@Component
public class SupplierConverter {


    /**
     * 转voList
     * @param
     * @return
     */
    public static List<SupplierVO> converterToSupplierVOList(List<Supplier> suppliers) {
        List<SupplierVO> supplierVOS=new ArrayList<>();
        if(!CollectionUtils.isEmpty(suppliers)){
            for (Supplier Supplier : suppliers) {
                SupplierVO supplierVO = new SupplierVO();
                BeanUtils.copyProperties(Supplier,supplierVO);
                supplierVOS.add(supplierVO);
            }
        }
        return supplierVOS;
    }
    public static SupplierVO converterToSupplierVO(Supplier supplier){
        SupplierVO supplierVO = new SupplierVO();
        BeanUtils.copyProperties(supplier,supplierVO);
        return supplierVO;
    }

}
